-
Couldn't load subscription status.
- Fork 2.4k
Add gamepad support to woodeneye-008 #14167
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
This needs to be adjusted to match the SDL coding style. |
Could you clarify what needs changing? |
| { | ||
| int i; | ||
| for (i = 0; i < players_len; i++) { | ||
| if (SDL_GetGamepadID(players[i].gamepad) == gamepad) return i; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the comment is about not always using curly braces, and indentation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, for example, here the code would be:
| if (SDL_GetGamepadID(players[i].gamepad) == gamepad) return i; | |
| if (SDL_GetGamepadID(players[i].gamepad) == gamepad) { | |
| return i; | |
| } |
| } | ||
| break; | ||
| } | ||
| case SDL_EVENT_GAMEPAD_AXIS_MOTION: { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I understand correctly, this event is fired only when the axis value changes. This implementation results in the camera only rotation when you wiggle the thumbstick, instead of the thumbstick controlling the velocity of camera rotation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's correct. If you want to have control based on state you should just query the axis value instead of responding to an axis change event.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also I’m pretty sure the convention is to use the right stick for camera controls rather than left. It’d be a little bit awkward having both movement and aim on the left side of the controller.
|
What I had in mind while writing the original example was to convey the following two messages to anyone reading the code:
While adding additional device support is technically an improvement, the extra complexity adds a little bit of additional cognitive load to the reader of the example, while not conveying the strictly minimum requirement. It also somewhat distracts from the uniqueness of mouse/keyboard splitscreen, I’d opine that a pointed omission of joystick support actually showcases the mouse/keyboard functionality better by distancing itself from traditional joystick implementation paradigms. I think multi-joystick would be better suited to a separate standalone demo, maybe one with a top down cooperative platformer format. It would also better show off the analog directional capabilities of the thumb sticks instead of shoehorning them into a WASD control scheme. |
|
That's fair feedback, and since @ccawley2011 seems to be away, I'll go ahead and close this for now. |
|
I probably ought to mention that the main reason for this PR is to better support systems like the 3DS, which doesn't have a keyboard and therefore requires this PR in order to allow input to work at all. |
In that case, can you clean up this PR based on our feedback, and I'll go ahead and merge it? |
No description provided.